package edu.tongji.engine.db.pojo;

import java.util.Date;

import edu.tongji.engine.common.Log;
import edu.tongji.engine.exe.Token;
import edu.tongji.engine.taskmgr.TaskMgrService;

/**
 * Task entity.
 * 
 * @author MyEclipse Persistence Tools
 */

public class Task implements java.io.Serializable {

	// Fields

	private Long id;
	private Token token;
	private Actor actor;
	private String name;
	private Date startTime;
	private Date endTime;
	private String state;



	// Property accessors

	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Token getToken() {
		return this.token;
	}

	public void setToken(Token token) {
		this.token = token;
	}

	public Actor getActor() {
		return this.actor;
	}

	public void setActor(Actor actor) {
		this.actor = actor;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Date getStartTime() {
		return this.startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	public Date getEndTime() {
		return this.endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public boolean endTask(){
		try{
			TaskMgrService taskService = new TaskMgrService();
			taskService.endTask(this);
			return true;
		}catch(Exception e){
			e.printStackTrace();
			Log.getLoger().loger.error("end task Error", e);
			return false;
		}
	}
}